package llama.core;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This class hold a map containing a IUser (key) and a boolean (value).
 * Every user is mapped to a boolean that tells if the user is a contact or not.
 */
public class SearchResults {
	private Map<IUser, Boolean> results;
	private ContactList contacts;
	
	public SearchResults(UserList users, ContactList contacts) {
		results = new LinkedHashMap<IUser, Boolean>();
		this.contacts = contacts;
		
		//Set up the map
		for(IUser user : users){
			results.put(user, isUserContact(user));
		}
	}
	
	private boolean isUserContact(IUser user){
		for(Contact contact : this.contacts){
			if(contact.getUser().equals(user)){ //Is the user a contact
				return true;
			}
		}
		
		return false;
	}
	
	public Map<IUser, Boolean> getResults(){
		return this.results;
	}
}
